<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    556. Next Greater Element III
   </h1>
   <p>
    Given a positive
    <strong>
     32-bit
    </strong>
    integer
    <strong>
     n
    </strong>
    , you need to find the smallest
    <strong>
     32-bit
    </strong>
    integer which has exactly the same digits existing in the integer
    <strong>
     n
    </strong>
    and is greater in value than n. If no such positive
    <strong>
     32-bit
    </strong>
    integer exists, you need to return -1.
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> 12
<strong>Output:</strong> 21
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> 21
<strong>Output:</strong> -1
</pre>
   <p>
    &nbsp;
   </p>
  </div>
  <div>
   <h1 class="question_title">
    556. 下一个更大元素 III
   </h1>
   <p>
    给定一个
    <strong>
     32位
    </strong>
    正整数&nbsp;
    <strong>
     n
    </strong>
    ，你需要找到最小的
    <strong>
     32位
    </strong>
    整数，其与&nbsp;
    <strong>
     n&nbsp;
    </strong>
    中存在的位数完全相同，并且其值大于n。如果不存在这样的
    <strong>
     32位
    </strong>
    整数，则返回-1。
   </p>
   <p>
    <strong>
     示例 1:
    </strong>
   </p>
   <pre>
<strong>输入:</strong> 12
<strong>输出:</strong> 21
</pre>
   <p>
    <strong>
     示例 2:
    </strong>
   </p>
   <pre>
<strong>输入:</strong> 21
<strong>输出:</strong> -1
</pre>
  </div>
 </body>
</html>